package day_2022_9_to_12.Day;

/**
 * @author haomin
 * @date 2022/10/02 17:03
 **/
public class Day31_1_Num777_CanTransform {
    class Solution {
        public boolean canTransform(String start, String end) {
            if(start.length() != end.length()) return false;
            int n = start.length();
            int i = 0, j = 0;
            while(true){
                while(i < n && start.charAt(i) == 'X') i++;
                while(j < n && end.charAt(j) == 'X') j++;
                if(i == n && j == n) break;

                if(i == n || j == n || start.charAt(i) != end.charAt(j)
                        || start.charAt(i) == 'L' && i < j || end.charAt(j) == 'R' && i > j)
                    return false;
            }
            return true;
        }
    }
}